package net.lovesrc.support.service.picprocess;

import com.google.common.base.Strings;
import net.coobird.thumbnailator.geometry.Positions;
import org.apache.commons.lang3.StringUtils;

import java.awt.*;

/**
 * 图片处理水印参数配置
 * @author gelic
 * Created in 23:26 2018/10/28
 * @since
 */
public class WatermarkConfig {

    /**
     * 缩放比例(>0)
     */
    private double scale = 1.0;

    /**
     * 输出质量(0-1)
     */
    private float quality = 1.0f;

    /**
     * 水印内容
     */
    private String content;

    /**
     * 字体名称(可选)
     */
    private String fontName;

    /**
     * 字体类型
     */
    private int fontStyle = Font.PLAIN;

    /**
     * 字体颜色
     */
    private Color fontColor = Color.WHITE;

    /**
     * 水印位置
     */
    private Positions positions = Positions.BOTTOM_CENTER;

    /**
     * 水印透明度
     */
    private float opacity = 1.0f;

    /**
     * 输出流文件格式(若输出为文件则可选,否则必选)
     */
    private String outputFormat;

    public WatermarkConfig(String content) {
        this.content = content;
    }

    public double getScale() {
        return scale;
    }

    public WatermarkConfig setScale(double scale) {
        this.scale = scale;
        return this;
    }

    public float getQuality() {
        return quality;
    }

    public WatermarkConfig setQuality(float quality) {
        this.quality = quality;
        return this;
    }

    public String getContent() {
        return content;
    }

    public WatermarkConfig setContent(String content) {
        this.content = content;
        return this;
    }

    public String getFontName() {
        return fontName;
    }

    public WatermarkConfig setFontName(String fontName) {
        this.fontName = fontName;
        return this;
    }

    public int getFontStyle() {
        return fontStyle;
    }

    public WatermarkConfig setFontStyle(int fontStyle) {
        this.fontStyle = fontStyle;
        return this;
    }

    public Color getFontColor() {
        return fontColor;
    }

    public WatermarkConfig setFontColor(Color fontColor) {
        this.fontColor = fontColor;
        return this;
    }

    public Positions getPositions() {
        return positions;
    }

    public WatermarkConfig setPositions(Positions positions) {
        this.positions = positions;
        return this;
    }

    public float getOpacity() {
        return opacity;
    }

    public WatermarkConfig setOpacity(float opacity) {
        this.opacity = opacity;
        return this;
    }

    public String getOutputFormat() {
        return outputFormat;
    }

    public WatermarkConfig setOutputFormat(String outputFormat) {
        this.outputFormat = outputFormat;
        return this;
    }

    public boolean isPrepare() {
        if(StringUtils.isEmpty(this.content)) {
            return false;
        }
        return true;
    }

}
